package fr.umlv.m2.jee.spij.persistence.schooling.dao;

import fr.umlv.m2.jee.spij.framework.dao.hibernate.AbstractHibernateDAO;
import fr.umlv.m2.jee.spij.persistence.schooling.IRegistrationDAO;
import fr.umlv.m2.jee.spij.persistence.schooling.Registration;
import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository("hibernateRegistrationDAO")
public class HibernateRegistrationDAO extends
        AbstractHibernateDAO<Long, Registration> implements IRegistrationDAO {

    @Override
    public List<Registration> findByLdapActor(String ldapActor) {
        Session session = getHibernateSession();
        Criteria criteria = session.createCriteria(Registration.class);
        criteria.add(Restrictions.eq("login", ldapActor));
        System.err.println("dans le find " + criteria.list().size());
        return criteria.list();
    }

}
